home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group01a.txt / 000071_icon-group-sender _Tue Jun 27 16:58:58 2000.msg < prev    next >
Internet Message Format  |  2002-01-03  |  2KB

  1. Return-Path: <icon-group-sender>
  2. Received: (from root@localhost)
  3.     by baskerville.CS.Arizona.EDU (8.9.1a/8.9.1) id QAA21141
  4.     for icon-group-addresses; Tue, 27 Jun 2000 16:58:51 -0700 (MST)
  5. Message-Id: <200006272358.QAA21141@baskerville.CS.Arizona.EDU>
  6. To: Gregg Townsend <gmt@baskerville.CS.Arizona.EDU>
  7. cc: Steve_Graham@labcorp.com, icon-group@optima.CS.Arizona.EDU,
  8.         wgg@cs.ucsd.edu
  9. Subject: Re: Permutations/Combinations 
  10. Date: Tue, 27 Jun 2000 13:28:05 -0700
  11. From: William Griswold <wgg@cs.ucsd.edu>
  12. Errors-To: icon-group-errors@optima.CS.Arizona.EDU
  13. Status: RO
  14. Content-Length: 1705
  15.  
  16. Or you can turn it around and generate all possible 6 letter permutations
  17. and run the results through a spell checker.  6 factorial isn't that bad. :)
  18. A small catch is that spell checkers tell you what is bad, rather than good,
  19. and some make mistakes and let stuff through.
  20.  
  21. procedure main(args)
  22.   every write(genstrings(cset(args[1])))
  23. end
  24.  
  25. procedure genstrings(chars)
  26.   if *chars = 1 then return chars
  27.   every c := !chars do
  28.     suspend (c || genstrings(chars -- c))
  29. end
  30.  
  31.  
  32. Here is a Unix shell script that completes the job:
  33.  
  34. #!/bin/csh
  35. set tmp = /tmp/tmp$$
  36.  
  37. permute $1 > $tmp.perm
  38. spell $tmp.perm > $tmp.misp
  39.  
  40. cat $tmp.misp $tmp.perm | sort | uniq -u
  41.  
  42. rm -f $tmp.perm $tmp.misp
  43.  
  44.  
  45. --bill
  46.  
  47. In msg <200006271949.MAA14033@baskerville.CS.Arizona.EDU>, Gregg Townsend says:
  48. >    From: "Steve Graham" <Steve_Graham@labcorp.com>
  49. >    
  50. >    We have a brain teaser floating around work whose object is to find all
  51. >    6-letter English words which can be made from the letters A, E, R, B,M
  52. >    and L.  I'm sure you can do this with Icon's reversible assignment,
  53. >    but I don't understand the latter.  Can anyone help me?
  54. >
  55. >If you have a list of English words, an easy solution to the brain teaser
  56. >is to run the list through this filter:
  57. >
  58. >    procedure main()
  59. >       local word
  60. >       while word := read() do
  61. >          if *word = 6 & cset(map(word)) == 'aerbml' then
  62. >         write(word)
  63. >    end
  64. >
  65. >Of course, I have managed to avoid entirely your question about
  66. >reversible assignment.
  67. >    
  68. >   ---------------------------------------------------------------------------
  69. >   Gregg Townsend         Staff Scientist      The University of Arizona
  70. >   gmt@cs.arizona.edu     Computer Science     Tucson, Arizona, USA
  71. >
  72. >
  73.